/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.haiberg.osgi.bundle.reportservice.factory;

import com.haiberg.osgi.bundle.reportservice.ReportFileHandler;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

/**
 *
 * @author gyue
 */
public class ReportFileHandlerFactory implements ServiceFactory<ReportFileHandler>{

    private int usageCounter = 0;

    @Override
    public ReportFileHandler getService(Bundle bundle, ServiceRegistration<ReportFileHandler> sr) {
        usageCounter++;
        System.out.println("create ReportFileHandler");
        return new ReportFileHandler();
    }

    @Override
    public void ungetService(Bundle bundle, ServiceRegistration<ReportFileHandler> sr, ReportFileHandler s) {
        usageCounter--;
        System.out.println("Number of bundles using ReportFileHandler service " + usageCounter);
    }
}
